package com.zxy.ziems.server.statistics.task;

import com.zxy.ziems.server.statistics.service.ZieceDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Slf4j
@Component
public class ZieceDataTask {

    @Autowired
    private ZieceDataService zieceDataService;

    // 各个数据对应的分类id
    private final String ELECTRICITY = "1899368856951009280";
    private final String WATER = "1899369128284721152";
//    private final String gas = "1899370346025398272";
//    private final String ac = "1904403813951930368";
//    private final String operationalData = "1902635319245697024";

    /**
     * 同步能管天数据给厂务
     * 每天0点30分执行
     */
    @Scheduled(cron = "0 30 0 * * ?")
    public void syncZieceElectricity() {
        log.info("============能管电数据同步厂务定时任务开始===============");
        // 昨天日期
        LocalDate date = LocalDate.now().minusDays(1);
        // 电数据
        zieceDataService.getElectricityData(ELECTRICITY, date);
        // 水数据
//        zieceDataService.getWaterData(WATER, date);
        log.info("============能管电数据同步厂务定时任务结束===============");
    }

}
